package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

public class IODemo6 {
    public static void main(String[] args) throws IOException {
       try(InputStream inputStream = new FileInputStream("d:/test.txt")) {
           //读文件
           //注意此处的read（），读取的是一个字节，且返回类型是int！！！
           while (true) {
               int b = inputStream.read();
               if (b == -1) {
                   //读到末尾返回-1.
                   break;
               }
               //System.out.println(b);
               System.out.printf("%x\n",b);//16进制打印结果
           }
       }
    }
}
